<template>
	<view class="mian">
		<!-- #ifdef MP-WEIXIN -->
			<navbar :bgColor="bgColor" :btnColors='btnColor' title="我的积分" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
		<!-- #endif -->	
		<view class="points_top">
			<view class="points">
				<view class="points_text">	可用积分	</view>
				<view class="points_val">	{{userInfo.points}}	</view>
				<view class="points_goods">
					<view class="points_goods_one" @click="change_goods()">
						兑换商品
					</view>
					<view class="points_goods_one"  @click="change_log()">
						积分明细
					</view>
					<view class="points_goods_one"  @click="change_goods_ok()">
						已兑换
					</view>
				</view>
			</view>
		</view>
		
		
		<view class="points_mian mt-20">
			<view class="flex align-center text-center border-b pb-20">								
				<text class="service_title pb-15" style="margin-top: 28rpx;margin-left: 10rpx;margin-bottom: -10rpx;">赚积分</text>
			</view>
			
			<view class="flex  justify-between align-center text-center  ml-30 border-b pb-30 pt-20 mr-20 mt-20" @click="dosign()">
				<view class="search_block">					
				   <image src="../../../static/resource/sign.png" mode="aspectFill" style="width: 36.42rpx; height: 35.64rpx;margin-top: 5rpx;position: absolute;margin-right: 20rpx;"></image>
				   <text class="mt-20 service_title pb-15 ml-40">每日签到</text>
				</view>					
				<u-icon name="arrow-right" color="#000" size="18"></u-icon>
			</view>			
			
			<view class="flex  justify-between align-center text-center  ml-30 border-b pb-30 pt-10 mr-20 mt-20">
				<view class="search_block">
					<image src="../../../static/resource/one_car.png" mode="aspectFill" style="width: 36.42rpx; height: 35.64rpx;margin-top: 5rpx;position: absolute;margin-right: 20rpx;"></image>
					<text class="mt-20 service_title pb-15 ml-40">首单购买</text>
				</view>
				<view class="" v-if="!userInfo.is_order" style="color: #999999;font-size: 26rpx;">
					去购买
				</view>	
				<view class="" v-if="userInfo.is_order" style="color: #999999;font-size: 26rpx;">
					已购买
				</view>
				<!-- <u-icon name="arrow-right" color="#000" size="18"></u-icon> -->
			</view>		
			<view class="ml-30 border-b pb-30 pt-10 mr-20 mt-20 ">
			<button class="flex justify-between align-center text-center button-service" open-type="share" @click="share">
			<!-- 	<view class="flex  justify-between align-center text-center  ml-30 border-b pb-20 pt-10 mr-20 mt-20"> -->
					<view class="search_block" style="margin-left: -5px;margin-top:-20rpx; margin-bottom: -20rpx;">
						<image src="../../../static/resource/group.png" mode="widthFix" style="width: 38.42rpx; height: 40.64rpx;margin-top: 25rpx;position: absolute;margin-right: 20rpx;"></image>
						<text class="mt-20 service_title pb-15 ml-40">邀请好友</text>
					</view>					
					<u-icon name="arrow-right" color="#000" size="18"></u-icon>
				<!-- </view> -->
		    </button>
			</view>
			
			
			
			<view class="flex  justify-between align-center text-center  ml-30 border-b pb-30 pt-10 mr-20 mt-20" @click="setmemberbase()">
				<view class="search_block">
					<image src="../../../static/resource/set_info.png" mode="scaleToFill" style="width:45rpx; height:38rpx;margin-top: 5rpx;position: absolute;margin-right: 20rpx;"></image>
					<text class="mt-20 service_title pb-15 ml-40">完善个人信息</text>
				</view>					
				<u-icon name="arrow-right" color="#000" size="18"></u-icon>
			</view>
			
			<view class="flex  justify-between align-center text-center  ml-30 border-b pb-30 pt-10 mr-20 mt-20" @click="read_goods">
				<view class="search_block">
					<image src="../../../static/resource/read.png" mode="aspectFill" style="width: 36.42rpx; height: 35.64rpx;margin-top: 5rpx;position: absolute;margin-right: 20rpx;"></image>
					<text class="mt-20 service_title pb-15 ml-40">首次订阅产品上新</text>
				</view>					
				<view class="no_read" v-if="!userInfo.is_read">
					订阅
				</view>
				<view class="no_reads" v-if="userInfo.is_read">
					已订阅
				</view>
			</view>
			
			
			<view class="flex  justify-between align-center text-center  ml-30 border-b pb-20 pt-10 mr-20 mt-20" @click="doactive">
				<view class="search_block">
					<image src="../../../static/resource/join.png" mode="aspectFill" style="width: 36.42rpx; height: 35.64rpx;margin-top: 5rpx;position: absolute;margin-right: 20rpx;"></image>
					<text class="mt-20 service_title pb-15 ml-40">参加活动</text>
				</view>					
				<u-icon name="arrow-right" color="#000" size="18"></u-icon>
			</view>
		</view>
		
		<view class="points_mian mt-20">
			<view class="flex align-center text-center border-b pb-20 pt-20">								
				<text class="mt-20 service_title pb-15">我能兑换</text>
			</view>
			
			
			<view class="goods_list">
				<view class=" flex flex-wrap" >                  
					<block v-for="(item,index) in list" :key="index">
						<view class="classify-cell-recom bg-white" @click="goDetails(item.id)">		
							<view class="doll_image">
								<image class="grid-img-recom" :src="item.goods_image"  mode="scaleToFill"></image>
							</view>	
							<view class="cate-zt flex flex-direction mt-10" >
								<view class="pl-20 pr-15 productNameText">{{item.goods_title}}</view>			 				            
							</view> 
							<view class="flex justify-between mt-20 align-center text-center mb-15 mr-10" >
								<view class="pl-20 pr-15">
									<span>积分</span>
									<span style="color: red;">{{item.goods_points}}</span>
								</view>	
								<view class="points_change">
									兑换
								</view>								
							</view> 					
			  			</view>
			  	    </block>   
										  
				</view> 
			</view>
		</view>
	</view>
	
</template>
 
<script>
	export default {
		data() {
			return {
				...getApp().globalData.config,		
				userInfo:'',	
				list:[]
			};
		},
		onShow() {
			this.query_member()
			this.query_goods_list()
		},		
		methods: {
			//获取用户信息
			query_member(){
				let user_info=uni.getStorageSync('userInfo');
				let that=this;
				if(user_info){
					let obj_data={
						token:user_info.token,
					};
					this.$http.getUser(obj_data).then(res=>{				
						if(res.resCode=='9999'){
							uni.setStorageSync('userInfo',res.data);	
						    that.userInfo=res.data
						}				
					})				
				}
			},
			//个人信息
			setmemberbase(){
				this.$routers.router('/pages/pagesuser/member_set/member_base','navigateTo') 
			},
			//兑换商品
			change_goods(){
				this.$routers.router('/pages/pagesuser/points/goods','navigateTo') 
			},
			//积分记录
			change_log(){
				this.$routers.router('/pages/pagesuser/points/log','navigateTo') 
			},
			//兑换商品
			change_goods_ok(){
				this.$routers.router('/pages/pagesuser/points/exchange','navigateTo') 
			},
			//签到
            dosign(){
				this.$routers.router('/pages/pagesuser/sign/index','navigateTo') 
			},
			//分享
			onShareAppMessage(){
				console.log('分享')
				return{
					provider:'weixin',
					title:'邀请好友使用YOMeeDoll!',
					path:'/pages/mine/index?recommendId='+this.userInfo.id,//页面 path ，必须是以 / 开头的完整路径
					imageUrl:'https://yomeedoll.qifudaren.net/static/upload/ca44c3de4c3f1856/9248ada602a392f3.jpg',
					desc:'',
				}
			},
			//参与活动
			doactive(){
				this.$routers.router('/pages/activity/list/index','navigateTo') 
			},
			//订阅
			read_goods(){
				let obj_data={
					token:uni.getStorageSync('userInfo').token,
					is_read:1,
				};
				this.$http.memberset(obj_data).then(res=>{				
					if(res.resCode=='9999'){
						this.query_member()
					}				
				})	
			},
			//获取信息
			query_goods_list(){
				let obj={
					currentAll:2,
					token:uni.getStorageSync('userInfo').token,
					page:1,
				}
				this.$http.pointsList(obj).then(res=>{
					if(res.resCode=='9999'){
						this.list =res.data.lists
					}
				})
			},
			//详情
			goDetails(id){
				this.$routers.router('/pages/pagesuser/points/detail?id='+id,'navigateTo') 
			}
			
		},
	};
</script>
 
<style scoped lang="scss">
	
		@import url("./index.css");
</style>